import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '线路名称',
    align:"center",
    dataIndex: 'routesName'
   },
   {
    title: '状态',
    align:"center",
    dataIndex: 'routesStatus_dictText'
   },
   {
    title: '线路类型',
    align:"center",
    dataIndex: 'routesType_dictText'
   },
   {
    title: '车牌号',
    align:"center",
    dataIndex: 'carNumber'
   },
   {
    title: '站点数',
    align:"center",
    dataIndex: 'siteNum'
   },
   {
    title: '学生数',
    align:"center",
    dataIndex: 'studentNum'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
     {
      label: "线路名称",
      field: "routesName",
      component: 'Input', //TODO 范围查询
      //colProps: {span: 6},
	},
	{
      label: "状态",
      field: "routesStatus",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"school_bus_routes_status"
      },
      //colProps: {span: 6},
 	},
	{
      label: "线路类型",
      field: "routesType",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"school_bus_routes_type"
      },
      //colProps: {span: 6},
 	},
   {
      label: "学生姓名",
      field: "studentName",
      component: 'Input', 
      //colProps: {span: 6},
	},
  {
    label: "学生学号",
    field: "studentCode",
    component: 'Input', 
    //colProps: {span: 6},
},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '线路名称',
    field: 'routesName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入线路名称!'},
          ];
     },
  },
  {
    label: '状态',
    field: 'routesStatus',
    defaultValue: "1",
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"school_bus_routes_status"
     },
  },
  {
    label: '线路类型',
    field: 'routesType',
    defaultValue: "1",
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"school_bus_routes_type"
     },
  },
  {
    label: '车牌号',
    field: 'carNumber',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表表格配置
export const schoolBusRoutesSiteColumns: JVxeColumn[] = [
    {
      title: '站点名称',
      key: 'siteName',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
      validateRules: [
        { required: true, message: '${title}不能为空' },
      ],
    },
    // {
    //   title: '站点经度',
    //   key: 'siteLongitude',
    //   type: JVxeTypes.input,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    // {
    //   title: '站点纬度',
    //   key: 'siteLatitude',
    //   type: JVxeTypes.input,
    //   width:"200px",
    //   placeholder: '请输入${title}',
    //   defaultValue:'',
    // },
    {
      title: '站点排序',
      key: 'siteSort',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:1,
        validateRules: [
          { required: true, message: '${title}不能为空' },
          { pattern: "n", message: "${title}格式不正确" }
        ],
    },
    {
      title: '站点状态',
      key: 'siteStatus',
      type: JVxeTypes.select,
      options:[],
      dictCode:"school_bus_site_status",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:"1",
    },
  ]


// 高级查询数据
export const superQuerySchema = {
  routesName: {title: '线路名称',order: 0,view: 'text', type: 'string',},
  routesStatus: {title: '状态',order: 1,view: 'list', type: 'string',dictCode: 'school_bus_routes_status',},
  routesType: {title: '线路类型',order: 2,view: 'list', type: 'string',dictCode: 'school_bus_routes_type',},
  carNumber: {title: '车牌号',order: 3,view: 'text', type: 'string',},
  //子表高级查询
  schoolBusRoutesSite: {
    title: '校车线路站点',
    view: 'table',
    fields: {
        routesId: {title: '校车线路',order: 0,view: 'list', type: 'string',dictTable: 'school_bus_routes', dictCode: 'id', dictText: 'routes_name',},
        siteName: {title: '站点名称',order: 1,view: 'text', type: 'string',},
        siteSort: {title: '站点排序',order: 4,view: 'number', type: 'number',},
        siteStatus: {title: '站点状态',order: 5,view: 'list', type: 'string',dictCode: 'school_bus_site_status',},
    }
  },
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}


//列表数据
export const studentColumns: BasicColumn[] = [
  {
   title: '学生姓名',
   align:"center",
   dataIndex: 'name'
  },
  {
   title: '学生学号',
   align:"center",
   dataIndex: 'code'
  },
  {
   title: '性别',
   align:"center",
   dataIndex: 'sex',
    customRender: ({ text }) => {
      return render.renderDict(text, 'sex');
    },
  },
  {
   title: '上车站点',
   align:"center",
   dataIndex: 'upSiteName'
  },
  {
   title: '下车站点',
   align:"center",
   dataIndex: 'downSiteName'
  },
];

//查询数据
export const studentSearchFormSchema: FormSchema[] = [
   {
      label: "学生姓名",
      field: "studentName",
      component: 'Input', 
      //colProps: {span: 6},
	},
  {
    label: "学生学号",
    field: "studentCode",
    component: 'Input', 
    //colProps: {span: 6},
},
];


//列表数据
export const siteColumns: BasicColumn[] = [
  {
   title: '站点名称',
   align:"center",
   dataIndex: 'siteName'
  },
  {
   title: '站点排序',
   align:"center",
   dataIndex: 'siteSort'
  },
  {
   title: '站点状态',
   align:"center",
   dataIndex: 'siteStatus_dictText'
  },
];

//查询数据
export const siteSearchFormSchema: FormSchema[] = [
   {
      label: "站点名称",
      field: "siteName",
      component: 'Input', 
      colProps: { span: 6 },
	},
];